<%@ page pageEncoding="UTF-8"%>

<!-- 删除商品信息框 -->
<div class="modal fade" id="deleteModal" tabindex="-1" role="dialog"
	aria-labelledby="exampleModalLabel">
	<div class="modal-dialog" role="document">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal"
					aria-label="Close">
					<span aria-hidden="true">&times;</span>
				</button>
				<h4 class="modal-title" id="exampleModalLabel">删除商品确认框</h4>
			</div>

			<div class="modal-body">
				<div class="form-horizontal">
					<div class="form-group">
						<label for="selectedid" class="col-sm-2 control-label">商品编号</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" id="selectedid"
								name="selectedid" value="" readonly="readonly">
						</div>
					</div>
					<div class="form-group">
						<label for="selectedname" class="col-sm-2 control-label">商品名称</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" id="selectedname"
								name="selectedname" value="" readonly="readonly">
						</div>
					</div>
					<div class="form-group">
						<label for="selectedprice" class="col-sm-2 control-label">商品价格</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" id="selectedprice"
								name="selectedprice" value="" readonly="readonly">
						</div>
					</div>
					<div class="form-group">
						<label for="selectedproduceTime" class="col-sm-2 control-label">生产日期</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" id="selectedproduceTime"
								name="selectedproduceTime" value="" readonly="readonly">
						</div>
					</div>
					<div class="form-group">
						<label for="selectedmadeFactory" class="col-sm-2 control-label">生产厂家</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" id="selectedmadeFactory"
								name="selectedmadeFactory" value="" readonly="readonly">
						</div>
					</div>
					<div class="form-group">
						<div class="col-sm-10">
							<input type="hidden" class="form-control" id="selectedPageNum"
								name="selectedPageNum" value="" readonly="readonly">
						</div>
					</div>
				</div>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
				<button type="button" class="btn btn-danger" id="deleteRecord">确认删除</button>
			</div>
		</div>
	</div>
</div>

<script type="text/javascript">
	$("#deleteRecord").click(function(){
		var pn=$("#selectedPageNum").val();
		//alert(pn);
		$.ajax({
			url:'${path}/delete.action',
			type:'post',
			data:{'id':$("#selectedid").val()},
			success:function(result){
				window.location.href='${path}/show.action?pn='+pn+'&time='+new Date();
			}
		});
	});
	
	function selectAll(){
		var selectSign=$("#selectAll").prop("checked");
		$("#info input[type=checkbox]").prop("checked",selectSign);
	}
	
	function deleteAll(){
		var pn=${page.pageNum};
		var checkComponents=$("#info input[type=checkbox]:checked:not('#selectAll')");
		var checkIds=[];
		if(confirm("确定删除所有记录吗？")){
			checkComponents.each(function(){
				$.ajax({
					url:'${path}/delete.action',
					type:'post',
					data:{'id':$(this).val()},
					success:function(result){
						window.location.href='${path}/show.action?pn='+${page.pageNum}+'&time='+new Date();
					}
				});
				
			});
		}
	}

	function values(ID, name, price, produceTime, madeFactory,pageNum) {
		$("#selectedid").val(ID);
		$("#selectedname").val(name);
		$("#selectedprice").val(price);
		$("#selectedproduceTime").val(produceTime);
		$("#selectedmadeFactory").val(madeFactory);
		$("#selectedPageNum").val(pageNum);
	};
</script>